// reduce + concat + isArray + 递归
//完美实现
let arr = [1,2,,null,[3,4,[5,6,[7,8]]]]
Array.prototype.myFlat = function(deep){
    if(deep<=0) return this
    let res = this
    res = res.reduce((n,l)=>{
        return Array.isArray(l) ? n.concat(l.myFlat(--deep)) : n.concat(l)
    },[])
    return res
}
console.log(arr.myFlat(3));